home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume91 / news / vnres112 / part03 / vn.c < prev   
Text File  |  1991-03-14  |  10KB  |  344 lines

  1. /*
  2. vn news reader for visual page oriented display of news
  3. aimed at scanning large numbers of articles.
  4.  
  5. Original program by Bob McQueer in several versions 1983-1986.  Released
  6. into the public domain in 1986.  While no copyright notice appears, the
  7. original author asks that a history of changes crediting the proper people
  8. be maintained.
  9.  
  10. Bob McQueer
  11. {amdahl, sun, mtxinu, hoptoad, cpsc6a}!rtech!bobm
  12.  
  13. History:
  14.  
  15.     (bobm@rtech) 5/86 - first "public" version
  16.  
  17.     (bobm@rtech) 12/86 - version incorporates:
  18.  
  19.         bug fixes:
  20.             str_store NULL string bug
  21.             not picking up first article in newsgroup
  22.             RESTART terminal reset for exit to editor.
  23.             skip whitespace in "empty" digest lines while unpacking
  24.             DISTRIBUTION line in followups.
  25.             :100%: prompt on last line in reader.
  26.             interpretation of multiple negations -w -t options.
  27.  
  28.             Many thanks to several people who noted the first
  29.             two bugs as well as fixes.
  30.  
  31.             Thank you to Karl Williamson for helpful information
  32.             tracking down the "concept terminal" bug (RESTART).
  33.  
  34.         SYSV ifdef's adapted from those done by Larry Tepper
  35.         at ATT Denver - sent in by Karl Williamson, drutx!khw.
  36.         Many people submitted SYSV ifdef's - thank you all.
  37.  
  38.         print capability from reader from Karl Williamson,
  39.         drutx!khw
  40.  
  41.         Changes to use alternate header lines for mail, from changes
  42.         by Andy Marrinson, andy@icom.UUCP (ihnp4!icom!andy).  Ifdef'ed
  43.         to allow local configuration (bobm@rtech).
  44.  
  45.         "author_copy" file for followups, prevention of multiple
  46.         "re: "'s, insert blank line and original author line
  47.         before excerpted text from Andy Marrinson, andy@icom.UUCP
  48.  
  49.         Search string capability in reader, from Lawrie Brown,
  50.         seismo!munnari!cdsadfa.oz!lpb (Australia).  Somewhat
  51.         modified by interaction with the :100%: bug.
  52.  
  53.         Arrow key support, adapted from changes by Lawrie Brown.
  54.         Modified to simply not allow control keys for arrows (allowing
  55.         SOME controls is too prone to problems, esp. with .vnkey), and
  56.         to allow the PAGEARROW ifdef (bobm@rtech)
  57.  
  58.         prevention of followups to "mod" and "announce", from
  59.         Lawrie Brown.
  60.  
  61.         OLDRC ifdef adapted from changes by Lawrie Brown.  ADDRMUNGE
  62.         added to allow OZ domain addressing changes from Australia
  63.         to be grafted back in, and provide a hook for anybody else
  64.         wanting to do something similar.
  65.  
  66.         Bob McQueer, bobm@rtech:
  67.  
  68.             a menu selection from the % command to jump to
  69.             a new newsgroup
  70.  
  71.             linked list on hash table - no longer a compiled
  72.             in limit for number of newsgroups
  73.  
  74.             .vnkey keystroke mapping file.
  75.  
  76.             options to get the % command list on entry, and to
  77.             change how unsubscribed groups are handled for updates.
  78.  
  79.             allow configurable use of vs / ve pair for terminal
  80.             handling.
  81.  
  82.     8/87 (bobm@rtech)
  83.  
  84.         Server interface changes.  Creation of vns_xxx routines
  85.         formally defining how to attach vn to an abstracted
  86.         news server, rearranged existing code to use that
  87.         abstraction.  Sourcefile list altered a good bit by
  88.         the rearrangement.  Some of this was splitting some
  89.         routines out from vn.c into smaller modules.  Reader
  90.         code was altered a good bit to work through the
  91.         ARTHEADER abstraction, rather than searching for
  92.         header lines.  Temp file writing code was the other
  93.         area heavily affected.  The std.c server interface
  94.         essentially incorporates the old newsrc.c code, plus
  95.         the old outgroup() and gethead() routines.
  96.  
  97.         vns_changes also included:
  98.  
  99.             Modification of mailer interface for MAILCHOOSE,
  100.             getting rid of ADDRMUNGE (superseded by vns
  101.             interface definition)
  102.  
  103.             Moved readstr() into the session loop code,
  104.             allowing a lot of static declarations to be
  105.             placed therein.  Also made it possible to
  106.             use strtok() underneath readstr().
  107.  
  108.             Made "save" write directly into file, rather
  109.             than forking a cat (gee, that sounds perverse).
  110.  
  111.             Also fixes it so that "|" save convention works
  112.             from reader.
  113.  
  114.             Digest unpacking has to know about header lines,
  115.             unfortunately, so it has local definitions for
  116.             some header lines.
  117.  
  118.         Incorporates:
  119.  
  120.             The much-discussed "continued header line" bug
  121.             fix, of course.  Includes the multiple header
  122.             line nfgets() by Andrew Worsley, andrew@munnari.oz,
  123.             with a couple cosmetic changes.
  124.  
  125.             Top / Middle / Bottom keys from Karl Williamson
  126.             print capability from reader from Karl Williamson,
  127.             drutx!khw
  128.  
  129.             Edit old save file changes from George Pavel,
  130.             gp@lll-lcc.arpa.  Used it to allow edit of
  131.             the some other old strings, too.
  132.  
  133.             Fix for the bad number input bug on the choose
  134.             new group from list feature, as reported by
  135.             Dave Tallman, tallman@hc.arpa.  His fix with
  136.             a few minor changes.
  137.  
  138.             A couple save file tweaks - allow a "%s" in VNSAVE
  139.             to specify individual directories by newsgroup.
  140.             Allow a "w:" prefix on filename to write instead
  141.             of appending, allow %d for article number in name.
  142.  
  143.             The VNEDITOR variable.
  144.  
  145.             Statistics collection ability.
  146.  
  147.             Update of .newsrc "read" number to reflect removed
  148.             articles, preventing rescanning of group on next
  149.             session.
  150.  
  151.             take out SIGHUP catching to avoid problems with
  152.             message being output.
  153.  
  154.             key to print version being used.
  155.  
  156.     Bug fixes following 12/87 posting.  Made this version 1/88 / res1.1
  157.     to distinguish.
  158.  
  159.         Digest extraction in reader.c, fix from steve@mahendo.  Thanks
  160.         to steve@mahendo & greg@mahendo for tracking down digest
  161.         extraction bugs.  I obviously didn't beat on the feature enough
  162.         after rearranging things to abstract the server interface.
  163.         The digest extraction display is a little less informative,
  164.         the price paid to allow mail & followup.
  165.  
  166.         SYS V ifdefs - svart.c, independently arrived at by several
  167.         people - thank you.  At the behest of a couple people I made
  168.         it spawn a "mkdir" instead of punting by calling mknod.
  169.  
  170.         Fix bug which would cause vn to crash if article has
  171.         no "From" / "Reply-to" / "Path" line. - std.c
  172.  
  173.         Fix bug preventing assignment of .newsrc to filesystem other
  174.         than that containing user's HOME.
  175.  
  176.         Fix excessive allocation in hash.c
  177.  
  178.         Handle duplicate active list records more gracefully.
  179.  
  180.         term_set(RESTART) call added to recovery from being
  181.         backgrounded in sig_set.c, in case something you ran while
  182.         backgrounded messed up your terminal state.  I lost the name
  183.         of the person reporting the problem & fix - my apologies.
  184.  
  185.         display optimization in reader.c which repaints instead of
  186.         scrolling if indicated by user's MORE variable.  This came
  187.         from Greg Earle, earle@mahendo.  Modified slightly for
  188.         cosmetic reasons & to fix a small folded-line bug.
  189.  
  190.     2/88 (bobm)
  191.  
  192.         Put mode on open() call in temp_open, as per bug fix from
  193.         Don Craig.  This has been working this way a long time on
  194.         a lot of systems (the file is unlinked after creation, so
  195.         the actual mode doesn't really matter, and as long as your
  196.         open call doesn't check the unused bits a random argument
  197.         works), but it was wrong, anyway.
  198.  
  199.     4/88 (bobm)
  200.  
  201.         Change server interface a bit to allow more control over
  202.         saving features, and provide a more generalized interface
  203.         for the vns_ routines to hang interactive hooks from.
  204.         Allow vns_ layer knowledge of marks.  These changes
  205.         should allow future implementation of selective lists,
  206.         use of the interface for a mailer, extra functionality
  207.         add-on at the vns level, etc.
  208.  
  209.         incorporate changes to allow 8 bit intl. character set
  210.         in user strings - came from Marius Olafsson, marius@rhi.
  211.         Also made 0x7f a #define'ed mask in case you should want
  212.         to try allowing 8 bit command chars.
  213.  
  214.         Jay Maynard, splut!jay pointed out that the percentage
  215.         calculation in reader overflowed for a 327+ line article
  216.         on a 16 bit machine, and sent fix.
  217.  
  218.         std.c - fix "all.all" bug (any newsgroup names with
  219.         multiple "all"'s in them incorrectly converted into RE's
  220.         which would match practically nothing).  Up vns_Version
  221.         stamp to 1.2.
  222.  
  223.  
  224.         11/90 Michael Taylor
  225.         Amiga Port
  226. Known bugs:
  227.  
  228.     If your terminal init string contains a newline, I suspect you will
  229.     get an initial "stopped on tty output" if you fire up backgrounded.
  230.     Cooked mode until session is started probably saves us in a lot of
  231.     cases where the init string contains no newlines.  Can be fixed, but
  232.     it's esoteric enough that I don't want to add another file to the
  233.     "patched" list.
  234.  
  235.     non-erasure of stuff on prompt line when the new
  236.     string includes an escape sequence (like PS1 maybe)
  237.     because it doesn't realize that the escape sequence
  238.     won't overprint the existing stuff
  239.  
  240.     control-w and update on exit may not update pages which have been
  241.     scanned in funny orders by jumping into the middle of groups
  242.  
  243.     inaccurate numbers on '%' command results - reflect ranges, not
  244.     actual numbers of articles.
  245.  
  246.     no arrow keys recognized which don't begin with <escape>
  247.  
  248.     doesn't know about the version 2.11 'm' in active list, or
  249.     use the 'y' / 'n' either.
  250.  
  251.     crash due to embedding $\(\) type substring specifiers in regular
  252.     expressions.  Obscure and hard to fix in a proper and portable way.
  253.  
  254.     Spool numbers are kept in int, not long - it would take quite
  255.     a bit of scrubbing through the code to root out this 32-bit'ism.
  256.     I wish I had typedef'ed the things.
  257. */
  258. #include <stdio.h>
  259. #include "node.h"
  260. #include "tty.h"
  261. #include "brk.h"
  262.  
  263. extern int Lrec;
  264.  
  265. extern NODE **Newsorder;
  266. extern int Ncount;
  267.  
  268. extern int Listfirst, Nounsub;
  269.  
  270. #ifdef amiga
  271. char pr_buf[1024];
  272. #endif
  273.  
  274. main(argc,argv)
  275. int argc;
  276. char **argv;
  277. {
  278.     /*
  279.         initialize environment variables,
  280.         scan .newsrc file, using any command line options present.
  281.      */
  282.     term_set (START);
  283.     envir_set ();
  284.     sig_set (BRK_IN);
  285.  
  286.     stat_start();
  287.  
  288.     hashinit();
  289.     temp_open();
  290.  
  291.     vns_news (argc,argv,&Listfirst,&Nounsub);
  292.  
  293.     fw_done ();
  294.  
  295.     make_newsorder();
  296.  
  297.     tty_set (BACKSTOP);
  298.  
  299.     if (Lrec >= 0)
  300.         session ();
  301.     else
  302.     {
  303.         new_groups ();
  304.         fprintf (stderr,"\nNo News\n");
  305.     }
  306.  
  307. #ifndef    MINIX
  308.     tty_set (COOKED);
  309. #else
  310.     tty_set (XCOOKED);
  311. #endif
  312.  
  313. #ifdef MSDOS
  314.     {
  315.         extern char *Orgdir;
  316.  
  317.         if (chdir(Orgdir) < 0)
  318.             fprintf (stderr,
  319.                 "change to original directory, %s, failed",
  320.                 Orgdir);
  321.     }
  322. #endif
  323. #ifdef amiga
  324.     {
  325.         extern char *Orgdir;
  326.  
  327.         if (chdir(Orgdir) < 0)
  328.             fprintf (stderr,
  329.                 "change to original directory, %s, failed",
  330.                 Orgdir);
  331.     }
  332. #endif
  333.  
  334.     /* exiting, don't worry about FLG_ECHG resetting */
  335.     vns_write(Newsorder,Ncount);
  336.  
  337.     term_set (STOP);
  338.     vns_exit(0);
  339. #ifdef amiga
  340.     kill_tmp ();
  341. #endif
  342.     stat_end( Lrec >= 0 ? 1 : 0 );
  343. }
  344.